import { createRouter, createWebHashHistory } from "vue-router";
import { createRouterGuards } from "./routerGuards.js";
import { Layout } from "./constant.js";

import modules from "./modules";

const RootRoute = [
    {
        path: "/",
        name: "Root",
        redirect: "/home",
        component: Layout,
        meta: {
            title: "Root",
        },
        children: [modules.homeRouter, modules.statRouter],
    },
];

export const constantRouter = [...RootRoute];

const router = createRouter({
    history: createWebHashHistory(""),
    routes: constantRouter,
    strict: true,
});

export function setupRouter(app) {
    app.use(router);
    // 创建路由守卫
    createRouterGuards(router);
}
export default router;
